package com.mrdeer.common.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.mrdeer.common.base.Converter;
import com.mrdeer.common.entity.beans.PageEntity;
import com.mrdeer.common.entity.sys.RolePermission;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class RolePermissionDTO extends RolePermission implements Converter<RolePermission, RolePermissionDTO> {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PageEntity page;

    @Override
    public RolePermissionDTO convert(RolePermission rolePermission) {
        BeanUtils.copyProperties(rolePermission, this);
        return this;
    }

    @Override
    public void convert2Do(RolePermission rolePermission) {
        BeanUtils.copyProperties(this, rolePermission);
    }
}
